<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" href="skin/base.css">
        <link rel="stylesheet" href="skin/more.css">
	    <link rel="stylesheet" href="skin/btn.css" type="text/css" />
        <script src="js/zy_control.js"></script>
        <script src="js/zy_click.js"></script>
		<script src="js/login.js"></script>
		<script src="js/config.js"></script>
		<script src="js/common.js"></script>
    </head>
    <body ontouchstart>
        <div id="content">
        <div class="more">
			<ul>
				<li ontouchstart="zy_touch('down')" onclick="oauth('user')"><strong class="myinfo">我的主页</strong><em id="nick"></em></li>
				<li ontouchstart="zy_touch('down')" onclick="oauth('user_info')"><strong class="myinfo">我的资料</strong><em id="username"></em></li>
			</ul>
			<ul>
				<li ontouchstart="zy_touch('down')" onclick="uexWindow.open('user_skin', '0', 'user_skin.html', 2, '', '', 0x0)"><strong class="about">风格设置</strong><em id="user_skin"></em></li>
				<li ontouchstart="zy_touch('down')" onclick="ls_clear()"><strong class="about">清除缓存</strong></li>
			</ul>
			<ul>
				<li ontouchstart="zy_touch('down')" onclick="upgrade()"><strong class="about">版本更新</strong></li>
				<li ontouchstart="zy_touch('down')" onclick="help()"><strong class="about">软件帮助</strong></li>
				<li ontouchstart="zy_touch('down')" onclick="jump('about')"><strong class="about">关于我们</strong></li>
			</ul>
			<div class="button" id="button"></div>
            </div>
		</div>
    </body>
    <script>
    	zy_init();
		var Users = new Users({});
		
		function oklogin(msg){
			if(localStorage['access_token']){
				$$('button').innerHTML='<button class="cupid-green" onclick="logout()">退出登录</button>';
			}else{
				$$('nick').innerHTML='';
				$$('button').innerHTML='<button class="cupid-green" onclick="login()">用户登录</button>'
			}
			
			if(localStorage['skin_title']){
				$$('user_skin').innerHTML=localStorage['skin_title'];
			}else{
				$$('user_skin').innerHTML='默认风格';
			}
			
			if (msg != 'maindata') {
				uexWindow.toast("0", "5", msg, 5000);
			}
		}
		
		
		function help(){
			uexWindow.open('user_help', '0', 'user_help.html', 2, '', '', 0x0);
		}
		
		function ls_clear(){
			//localStorage..removeItem('');
			uexWindow.toast("0","5",'缓存清除成功',1000);
		}
		
		window.uexOnload=function(type){
			if(!type){
				uexWindow.setBounce("1");
				uexWindow.showBounceView("0","#666","0");
				uexWindow.showBounceView("1","#666","0");
		
				uexXmlHttpMgr.onData = function(opId, status, data){
					uexXmlHttpMgr.close(opId);
					if (status == 1) {
						data=JSON.parse(data);
						if (opId == 1) {
								if (data['success'] == 'yes') {
									uexWindow.confirm('软件更新', data['msg'], ["更新", "稍后"]);
									uexWindow.cbConfirm = function(cbopId, dataType, cbdata){
										if (cbdata == 0) {
											if (localStorage['device'] == 0) {
												loadLink(data['data']['iphone_updateFileUrl']);
											}else if (localStorage['device'] == 1) {
												loadLink(data['data']['android_File']);
											}
										}else {
											return;
										}
									}
								}else if (data['success'] == 'no') {
									uexWindow.alert('软件更新', data['msg'], '关闭');
								}else {
									uexWindow.alert('软件更新', data['msg'], '关闭');
								}
							
						}
					}else if (status == -1) {
						uexWindow.alert('错误提示', '获取超时，请重试~', '关闭');
					}
				}
				
				oklogin('maindata');
			}
		}
		
		function upgrade(){
			var url = 'http://www.jonker.cc/oschina/upgrade.php?&ver='+localStorage['version']+'&platform='+localStorage['device'];;
			uexXmlHttpMgr.open(1,'post',url,"8000");
			uexXmlHttpMgr.send(1);
		}
		
		function oauth(windowname){
			if(!Users.checkUser()){
				windowname='login';
				localStorage['login']="more";
			}
			if(windowname == 'user_talk'){
				localStorage['userid'] = localStorage['u_id'];
			}
			uexWindow.open(windowname, '0', windowname+'.html', 2, '', '', 0x0);
		}
		
		function login(){
			localStorage['login']="more";
			uexWindow.open('login', '0', 'login.html', 2, '', '', 0x0);
		}
		
		function jump(windowname){
			uexWindow.open(windowname, '0', windowname+'.html', 2, '', '', 0x0);
		}
		
		function logout(){
			Users.logout();
			oklogin("退出成功~");
　　		}

    </script>
</html>